﻿using Microsoft.AspNetCore.Mvc;
using tools.common;

namespace tools.api.Controllers
{
    /// <summary>
    /// 通用工具操作
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CommonController : ControllerBase
    {
        [HttpGet]
        public IActionResult ToBase64(string? filePath)
        {
            return Ok(FileTool.ToBase64(filePath));
        }

        [HttpPost]
        public IActionResult Base64Save([FromForm] string? base64String, [FromForm] string? filePath)
        {
            FileTool.Base64Save(base64String, filePath);
            return NoContent();
        }

        [HttpPost]
        public IActionResult CombineAndCreateDirectory(string[] pathSections)
        {
            return Ok(PathTool.CombineAndCreateDirectory(pathSections));
        }
    }
}
